Skip to content

Conversation

@Bencheng21
Copy link
Contributor

No description provided.

},
})
if err != nil {
if isRatelimited(resp) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I add isRatelimited to Every API calls, including List and Grants

for {
orgs, resp, err := client.Organizations.List(ctx, "", &github.ListOptions{Page: page, PerPage: maxPageSize})
if err != nil {
if isRatelimited(resp) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's Validate function, baton-sdk doesn't do the retry for Validate function, I don't know why we have to handle with this error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are adding retry

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and also the error message is not correct

can you return an error instead of nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, that makes sense. TIL

orgs, resp, err := o.client.Organizations.List(ctx, "", opts)
if err != nil {
if isRatelimited(resp) {
return nil, "", nil, uhttp.WrapErrors(codes.Unavailable, "too many requests", err)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Add isRatelimited to List()

if err != nil {
if isRatelimited(res) {
return nil, "", nil, uhttp.WrapErrors(codes.Unavailable, "too many requests", err)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: GitHub API Client Nil Response Handling

The isRatelimited function is called on GitHub API responses without a preceding nil check. GitHub API client methods can return a nil response object alongside an error (e.g., due to network issues or specific undocumented API behaviors like Users.GetByID), leading to nil pointer dereferences.

Locations (2)

Fix in CursorFix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isRatelimited has checked nil pointer.

@Bencheng21 Bencheng21 merged commit 092c0c9 into main Jul 24, 2025
3 checks passed
@Bencheng21 Bencheng21 deleted the INC300_IncludeAccessTokenError branch July 24, 2025 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants